home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / wgt_tp1.zip / WGT03.PAS < prev    next >
Pascal/Delphi Source File  |  1992-07-05  |  3KB  |  86 lines

  1. {**************************************************************************
  2.                           WordUp Graphics Toolkit
  3.                                  Demo File
  4.                              Benchmark Testing
  5.  
  6.  This file allows you to time the various routines in the WGT as compared
  7.  to the BGI. Simply replace the two indicated lines in the main part of the
  8.  program with commands such as:
  9.          CIRCLE         ,       _CIRCLE
  10.          RECTANGLE      ,       _RECTANGLE
  11.          BOX            ,       _BOX
  12.          LINE           ,       _LINE
  13.          PUTPIXEL       ,       _PUTPIXEL
  14.          GETPIXEL       ,       _GETPIXEL
  15.  **************************************************************************}
  16.  
  17. USES DOS, Graph, WGT;
  18.  
  19. VAR
  20.    grDriver, grMode : INTEGER;
  21.    ctr : INTEGER;
  22.    p : PALETTE;     { This is a type specific to WGT }
  23.    h, h1, m, m1, s, s1, s100, s1001 : word; {Timing variables}
  24.    h2,h3,m2, m3,s2, s3, s1002,s1003 : word;
  25.  
  26.  
  27. FUNCTION SortTime (sthr, finhr, stmin, finmin,
  28.                  stsec, finsec, sts100, fins100 : word) : integer;
  29.  
  30. {  This function returns the difference of two times in  }
  31. {   hundredths of a second. (Must be less than 32767)    }
  32.  
  33. VAR
  34.     time : integer;
  35.  
  36. BEGIN
  37.  
  38.     { Check whether time goes over midnight }
  39.  
  40.     IF (sthr = 23) and (finhr = 0) THEN
  41.       finhr := 24;
  42.  
  43.     { Compute time in stages to prevent overflow }
  44.  
  45.     SortTime :=(((finhr - sthr) * 60 + (finmin - stmin)) * 60
  46.                    + (finsec - stsec)) * 100 + (fins100 - sts100)
  47. END;
  48.  
  49.  
  50. BEGIN
  51.      { Initialize graphics (see demo file #1) }
  52.      grDriver := INSTALLUSERDRIVER('VGA256',NIL);
  53.      grMode := 0;
  54.      INITGRAPH(grDriver,grMode,'c:\tp\bgi');
  55.  
  56.      { First load the demo palette file }
  57.      Load_Palette('demo.pal',p);
  58.  
  59.      _SETCOLOR(50);
  60.      GetTime (h, m, s, s100);   { Get start time of WGT routine }
  61.              { Place your benchmark routine on the next line (WGT version) }
  62.              for ctr:=0 to 199 do _line(0,ctr,319,ctr);
  63.  
  64.      GetTime (h1, m1, s1, s1001); { Get finish time }
  65.  
  66.  
  67.      _SETCOLOR(100);
  68.      GetTime (h2, m2, s2, s1002);
  69.              { Place the benchmark routine here with the BGI version }
  70.              for ctr:=0 to 199 do line(0,ctr,319,ctr);
  71.  
  72.      GetTime (h3, m3, s3, s1003);
  73.  
  74.  
  75.      { Now close the graphics system }
  76.  
  77.      CLOSEGRAPH;
  78.  
  79.      {Display times}
  80.  
  81.      writeln ('Time to do the routine (in hundredths of a second) WGT:',
  82.                SortTime (h, h1, m, m1, s, s1, s100, s1001) : 6);
  83.  
  84.      writeln ('Time to do the routine (in hundredths of a second) BGI:',
  85.                SortTime (h2, h3, m2, m3, s2, s3, s1002, s1003) : 6);
  86. END.